
package com.kweative.model.query;

import com.kweative.model.Table;
import com.kweative.model.exception.ColumnNotFoundException;
import com.kweative.model.column.Column;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author henrik
 */
public class OnStatement<T extends Table,P extends WhereStatement> extends WhereStatement<OnStatement<T,P>,T> {
    P parent;
    public OnStatement(T primTable,P parent) {
        super(primTable);
        this.parent = parent;
    }

    @Override
    public String compile() {
        try {
            return compileWherePhrase();
        } catch (ColumnNotFoundException ex) {
            Logger.getLogger(OnStatement.class.getName()).log(Level.SEVERE, null, ex);
        }
        return "";
    }
    public P columns(Column<?,T> ... cols) {
        if (cols.length > 0) {
            if (parent instanceof Select) {
                ((Select)parent).columns(cols);
            }
        }
        return parent;
    }
    public P end() {
        return parent;
    }


}
